FROM golang:alpine3.15 As builder

ENV CGO_ENABLED 0
ENV GOOS linux
ENV GOPROXY https://goproxy.cn,direct

WORKDIR /app

ADD . /app

RUN go mod download

RUN go build -ldflags="-s -w" -o app ./src/main.go

FROM alpine

WORKDIR workspace
COPY --from=builder /app/app .
COPY --from=builder /app/etc/app.yaml .

CMD ["./app","service","-c","./app.yaml"]
